//
//  ForgotPWViewController.m
//  OrderFood
//
//  Created by xiaofang wang on 2018/10/22.
//  Copyright © 2018年 zhiyuan. All rights reserved.
//

#import "ForgotPWViewController.h"
#import "NextFindPWViewController.h"
@interface ForgotPWViewController ()
{
    NSTimer* mytimer;   //计时器
    NSInteger timerCount;   //
}
@property (nonatomic,strong) UITextField *accountTF;
@property (nonatomic,strong) UITextField *captchaTF;
@property (nonatomic,strong) UIButton *btnGetCode;
@property (nonatomic,strong) UIView* codeLine;
@property (nonatomic,strong) UIButton *nextBtn;


@end

@implementation ForgotPWViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.name = @"找回密码";
    
    [self setupUI];
}

-(void)setupUI{
    for (int i = 0; i < 2; i++) {
        [QTTools tool_addLineWithFrame:CGRectMake(15, 150+50*i, SCREEN_WIDTH - 30, 1) superView:self.view];
    }
    
    self.accountTF = [[UITextField alloc] initWithFrame:CGRectMake(15, 100, SCREEN_WIDTH-110, 50)];
    self.accountTF.placeholder = @"请输入手机号";
    [self.accountTF setValue:themeTextColor forKeyPath:@"_placeholderLabel.textColor"];
    [self.accountTF setValue:[UIFont systemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];
    self.accountTF.keyboardType = UIKeyboardTypeNumberPad;
    [self.view addSubview:self.accountTF];
    
    UIButton *btnGetCode = [UIButton buttonWithType:UIButtonTypeCustom];
    btnGetCode.frame = CGRectMake(SCREEN_WIDTH-95, GetMinY(self.accountTF)+15, 80, 20);
//    btnGetCode.backgroundColor = [UIColor greenColor];
    [btnGetCode setTitle:@"发送验证码" forState:UIControlStateNormal];
    btnGetCode.titleLabel.font = FONT(15);
    [btnGetCode setTitleColor:themeColor forState:UIControlStateNormal];
    [self.view addSubview:btnGetCode];
    [btnGetCode addTarget:self action:@selector(getCodeAction:) forControlEvents:UIControlEventTouchUpInside];
    self.btnGetCode = btnGetCode;
    
    UIView* codeLine = [[UIView alloc] initWithFrame:CGRectMake(GetMinX(btnGetCode), GetMaxY(btnGetCode), GetWidth(btnGetCode), 1)];
    codeLine.backgroundColor = themeColor;
    [self.view addSubview:codeLine];
    
    
   
    
    self.captchaTF = [[UITextField alloc] initWithFrame:CGRectMake(15, 100+50, SCREEN_WIDTH-110, 50)];
    self.captchaTF.placeholder = @"请输入验证码";
    [self.captchaTF setValue:themeTextColor forKeyPath:@"_placeholderLabel.textColor"];
    [self.captchaTF setValue:[UIFont systemFontOfSize:15] forKeyPath:@"_placeholderLabel.font"];
    self.captchaTF.secureTextEntry = YES;
    self.captchaTF.keyboardType = UIKeyboardTypeNumberPad;
    [self.view addSubview:self.captchaTF];
    
    
    _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _nextBtn.frame = CGRectMake(15, GetMaxY(self.captchaTF)+35, SCREEN_WIDTH-30, 44);
    _nextBtn.backgroundColor = themeColor;
    _nextBtn.layer.cornerRadius = 5;
    _nextBtn.layer.masksToBounds = YES;
    _nextBtn.titleLabel.font = [UIFont boldSystemFontOfSize:17];
    [_nextBtn setTitleColor:WHITECOLOR forState:UIControlStateNormal];
    [_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
    [_nextBtn addTarget:self action:@selector(nextAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.nextBtn];
    
}
-(void)nextAction:(UIButton *)sender{
    if ([QTTools isBlankString:self.accountTF.text]) {
        ShowMessage(@"请输入手机号");
        return;
    }else if (![QTTools tool_objectPhoneNumber:self.accountTF.text]){
        ShowMessage(@"请输入正确的手机号");
        return;
    }
    
    NextFindPWViewController *vc = [NextFindPWViewController new];
    vc.phoneNum = self.accountTF.text;
    [self.navigationController pushViewController:vc animated:YES];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
